/* ------------------------------------------------------------------ Support code for problem set #5 Tom Annau ------------------------------------------------------------------- */ #ifndef support_hh #define support_hh #include "vector.hh" #include "matrix.hh" // Read data from filename into two matrices, input and output // input[i] is a vector which is the input data for training example // #i, and similarly, output[i] is the output data void read_data(string filename, matrix& input, matrix& output); // Returns a random number between -1 and 1 double random_number(); // Read double parameter from file "parameters" // See the file "parameters" for examples void read_parameter(string& parameter_name, double& parameter, double default_value); // Read int parameter from file "parameters" void read_parameter(string& parameter_name, int& parameter, int default_value); // Take n-dimensional vector v, return a vector which is n+1 dimensions // and has as its first n entries the entries of v; as its last entry, // it has a 1. This is useful for adding a bias unit. vector augment(vector& v); // Return pseudoinverse of matrix M. // This is for those of you who want to implement Levenberg descent. matrix pseudoinverse(matrix& M); // Return the square of its argument, may or may not be useful inline double square_of(double x) { return x * x; } #endif